package edu.lingnan.house.controller;

import edu.lingnan.house.pojo.TbBooking;
import edu.lingnan.house.service.BookService_lxj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class BookController_lxj {

    @Autowired
    private BookService_lxj bookService;

    //中介查询负责的未审批预约申请
    @GetMapping("/b1")
    @ResponseBody
    public List<TbBooking> testFindBookByAgentId(String agentId){
        List<TbBooking> books = bookService.findBookByAgentIdAndState1(agentId);
        return books;
    }

    //中介查询负责的的已审批预约
    @GetMapping("/b2")
    @ResponseBody
    public List<TbBooking> testFindBookByAgentIdTo2(String agentId) {
        List<TbBooking> bookings = bookService.findBookByAgentIdAndState2(agentId);
        return bookings;
    }

    //中介审批通过客户预约申请
    @PostMapping("/b3")
    @ResponseBody
    public String testUpdateBookApply2(@RequestBody TbBooking booking){
        int i = bookService.updateBookByAgent2(booking);
        return "ok";
    }

    //中介审批不通过客户预约申请
    @PostMapping("/b4")
    @ResponseBody
    public String testUpdateBookApply4(@RequestBody TbBooking booking){
        int i = bookService.updateBookByAgent4(booking);
        return "ok";
    }
}
